package com.base.logistics.jdl.bean.trace;

import com.base.logistics.jdl.util.json.JdlGsonBuilder;
import com.base.logistics.jdl.bean.RequestParams;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * <pre>
 * 查询物流轨迹（商家用）请求对象
 * </pre>
 * @since 2021-02-19
 */
public class QueryTraceRequestParams extends RequestParams  implements Serializable {

    /**
     * 服务域
     */
    private static final String LOP_DN= "express";

    /**
     * code字段
     */
    private static final String CODE_FIELD = "code";

    /**
     * 成功状态码
     */
    private static final Integer SUCCESS_CODE = 100;

    /**
     * API url
     */
    private static final String METHOD = "/TraceQueryJsf/queryTrace";

    /**
     * 查询物流轨迹对象
     * <pre>
     * 是否必填：是
     * </pre>
     */
    private TraceQueryDTO queryDTO;

    QueryTraceRequestParams(TraceQueryDTO queryDTO) {
        this.queryDTO = queryDTO;
    }

    public static QueryTraceRequestParamsBuilder builder() {
        return new QueryTraceRequestParamsBuilder();
    }

    /**
     * 获取返回状态码字段
     * @return 返回状态码字段
     */
    @Override
    public String getCodeField() {
        return CODE_FIELD;
    }

    /**
     * 获取成功返回状态码
     * @return 成功返回状态码
     */
    @Override
    public Integer getSuccessCode() {
        return SUCCESS_CODE;
    }

    /**
     * 获取请求json数据
     * @return 请求json数据
     */
    @Override
    public String getJsonParams() {
        List<TraceQueryDTO> list = new ArrayList<>();
        list.add(this.queryDTO);
        return JdlGsonBuilder.create().toJson(list);
    }

    /**
     * 获取服务域
     * @return 服务域
     */
    @Override
    public String getLopDn(){
        return LOP_DN;
    }

    /**
     * 获取API url
     * @return API url
     */
    @Override
    public String getMethod(){
        return METHOD;
    }

    public TraceQueryDTO getQueryDTO() {
        return this.queryDTO;
    }

    public void setQueryDTO(TraceQueryDTO queryDTO) {
        this.queryDTO = queryDTO;
    }

    public String toString() {
        return "QueryTraceRequestParams(queryDTO=" + this.getQueryDTO() + ")";
    }

    public boolean equals(final Object o) {
        if (o == this) return true;
        if (!(o instanceof QueryTraceRequestParams)) return false;
        final QueryTraceRequestParams other = (QueryTraceRequestParams) o;
        if (!other.canEqual((Object) this)) return false;
        if (!super.equals(o)) return false;
        final Object this$queryDTO = this.getQueryDTO();
        final Object other$queryDTO = other.getQueryDTO();
        if (this$queryDTO == null ? other$queryDTO != null : !this$queryDTO.equals(other$queryDTO)) return false;
        return true;
    }

    protected boolean canEqual(final Object other) {
        return other instanceof QueryTraceRequestParams;
    }

    public int hashCode() {
        final int PRIME = 59;
        int result = super.hashCode();
        final Object $queryDTO = this.getQueryDTO();
        result = result * PRIME + ($queryDTO == null ? 43 : $queryDTO.hashCode());
        return result;
    }

    public static class QueryTraceRequestParamsBuilder {
        private TraceQueryDTO queryDTO;

        QueryTraceRequestParamsBuilder() {
        }

        public QueryTraceRequestParamsBuilder queryDTO(TraceQueryDTO queryDTO) {
            this.queryDTO = queryDTO;
            return this;
        }

        public QueryTraceRequestParams build() {
            return new QueryTraceRequestParams(queryDTO);
        }

        public String toString() {
            return "QueryTraceRequestParams.QueryTraceRequestParamsBuilder(queryDTO=" + this.queryDTO + ")";
        }
    }
}
